package org.example.mapper;

import org.apache.ibatis.annotations.*;
import org.example.entity.Orders;
import java.util.List;

public interface IOrdersMapper {
    // 插入订单记录，确保插入语句包括 order_date 字段
    @Insert("INSERT INTO orders (user_id, business_id, da_id, order_total, order_state, order_date) VALUES (#{userId}, #{businessId}, #{daId}, #{orderTotal}, #{orderState}, #{orderDate})")
    @Options(useGeneratedKeys = true, keyProperty = "orderId")
    void insert(Orders orders);

    // 根据订单ID查询订单
    @Select("SELECT * FROM orders WHERE order_id = #{orderId}")
    Orders selectById(@Param("orderId") Integer orderId);

    // 根据用户ID查询所有订单
    @Select("SELECT * FROM orders WHERE user_id = #{userId}")
    List<Orders> selectListByUserId(@Param("userId") String userId);
} 